<template>
  <!-- 通用查看签到弹框 -->
  <a-modal
    :footer="null"
    title="一、二级风险详情"
    @cancel="handleClose"
    @ok="handleClose"
    :visible="visible"
    class="normal-modal"
  >
    <b-table
      ref="table"
      :columns="column"
      :request="loadData"
      :show-page="false"
    >
    </b-table>
  </a-modal>
</template>

<script>
import { findInventorys } from '@/api/safetySupervision/safetySystem'


export default {
  props: {
    params: {
      type: Object,
      default: {}
    },
    visible: {
      type: Boolean,
      default: false
    }

  },
  data() {
    return {
      column: [
        { title: '区域', dataIndex: 'areaName',ellipsis: true, width: '15%'},
        { title: '分部分项工程', dataIndex: 'itemTypeStr',ellipsis: true, width: '15%'},
        // { title: '预计实施时间开始', dataIndex: 'planTime' },
        {
          title: '预计实施时间', dataIndex: 'planTime',
          ellipsis: true, width: '20%',
          customRender: (text, record, index) => {
            return record.planTime + '~' + record.planTimeEnd
          }
        },
        // { title: '预计实施时间结束', dataIndex: 'planTimeEnd' },
        { title: '危险参数', dataIndex: 'parameter',ellipsis: true, width: '40%'},
        { title: '风险等级', dataIndex: 'levelTypeStr',ellipsis: true, width: '10%'}
      ],
      loadData: async q => {
        let [err, res] = await findInventorys(Object.assign(q, {
          projectId: this.params.projectId,
          takeShiftId: this.params.id
        }))
        if (!err) return res
        return { code: this.SUCCESS_CODE, data: [] }
      }
    }
  },
  methods: {
    handleClose() {
      this.$emit('update:visible', false)
    }
  },
  watch: {
    visible(v) {
      if (v) {
        this.$nextTick(() => {
          this.$refs.table.refresh()
        })
      }
    }
  }
}
</script>

